<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0' xmlns='http://www.w3.org/1999/xhtml'>
	<xsl:output method='text' encoding='utf-8'/>

<xsl:template match='/'>/*
 * model_table.c
 *
 * Created: 30.07.2012 12:39:29
 *  Author: OliverS
 *
 * $Id: model_table.c 48 2013-02-27 16:30:26Z olischulz24@googlemail.com $
 *
 * --> this file is automatically generated. Do not modify.
 */

// number of models:   <xsl:value-of select='count(//model)'/>
// number of channels: <xsl:value-of select='count(//channel)'/>

#include "global.h"
#include "mixer.h"
#include &lt;avr/pgmspace.h&gt;

#ifndef P_STR
#define P_STR static const char PROGMEM
#endif

// ------------ model names
<xsl:for-each select='//model'>P_STR strModel<xsl:number format='01'/>[] = "<xsl:value-of select='@name'/>";
</xsl:for-each>

// ------------ model definitions
<xsl:for-each select='//model'>// <xsl:value-of select='@name'/>
static const model_t model<xsl:number format='01'/> PROGMEM =
{
    strModel<xsl:number format='01'/>, <xsl:value-of select='count(channel)'/>,
    {
        //  thr   ail   ele   rud  offs  flags
<xsl:for-each select ='channel'>        {{ <xsl:call-template name='lpad4'>
<xsl:with-param name='value' select='@throttle'/></xsl:call-template>, <xsl:call-template name='lpad4'>
<xsl:with-param name='value' select='@aileron'/></xsl:call-template>, <xsl:call-template name='lpad4'>
<xsl:with-param name='value' select='@elevator'/></xsl:call-template>, <xsl:call-template name='lpad4'>
<xsl:with-param name='value' select='@rudder'/></xsl:call-template>, <xsl:call-template name='lpad4'>
<xsl:with-param name='value' select='@offset'/></xsl:call-template>, <xsl:choose>
	<xsl:when test='@type="motor"'>FLAG_ESC</xsl:when>
	<xsl:otherwise>FLAG_SERVO</xsl:otherwise>
</xsl:choose> }},
</xsl:for-each>    }
};

</xsl:for-each>
// ------------ model table
const model_t* const modelTable[] PROGMEM = {<xsl:for-each select='//model'>
    &amp;model<xsl:number format='01' />,</xsl:for-each>
};
</xsl:template>
<xsl:template name='lpad4'>
<xsl:param name='value'/>
<xsl:variable name='val'>
	<xsl:choose>
		<xsl:when test='string-length(string($value)) != 0'>
			<xsl:value-of select='string($value)'/>
		</xsl:when>
		<xsl:otherwise>0</xsl:otherwise>
	</xsl:choose>
</xsl:variable>
<xsl:value-of select='substring(concat("    ", $val), string-length($val) + 1, 4)'/>
</xsl:template>
</xsl:stylesheet>
